package top.pmwly.common.domain;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import top.pmwly.dao.pojo.SysUser;

import java.io.Serializable;
import java.util.Collection;

/**
 * @author Herther
 * @version 1.0.0
 * @ClassName UserDetails.java
 * @Description 重写UserDetails
 * @createTime 2021年09月21日 18:50:00
 */
@Data
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="SysUser对象", description="用户信息表")
public class UserSecurity   implements Serializable, UserDetails {

    private static final long serialVersionUID = 1L;

    //@ApiModelProperty(value = "用户ID")
    //private Long userId;
    //
    //@ApiModelProperty(value = "角色关联用户表id")
    //private Long roleUserId;
    //
    //@ApiModelProperty(value = "用户账号")
    //private String userName;
    //
    //@ApiModelProperty(value = "用户昵称")
    //private String nickName;
    //
    //@ApiModelProperty(value = "用户邮箱")
    //private String email;
    //
    //@ApiModelProperty(value = "手机号码")
    //private String phone;
    //
    //@ApiModelProperty(value = "用户性别（0男 1女 2未知）")
    //private String sex;
    //
    //@ApiModelProperty(value = "头像地址")
    //private String avatar;
    //
    //@ApiModelProperty(value = "密码")
    //private String password;
    //
    //@ApiModelProperty(value = "帐号状态（0正常 1停用）")
    //private String status;
    //
    //@ApiModelProperty(value = "删除标志（0代表存在 2代表删除）")
    //private String delFlag;
    //
    //@ApiModelProperty(value = "备注")
    //private String remark;
    //
    //@ApiModelProperty(value = "创建时间")
    //private Date createTime;
    //
    //@ApiModelProperty(value = "更新时间")
    //private Date updateTime;

    private SysUser sysUser;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return sysUser.getPassword();
    }

    @Override
    public String getUsername() {
        return sysUser.getUserName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return "0".equals(sysUser.getStatus()) ? true:false;
    }
}
